<#-- 分页组件
labelHref:分页按钮的链接,页码占位符$page
labelCurrent:当前页码
labelCount:总页码数量
-->
<#macro pagination labelHref labelCurrent labelCount>
<ul class="pagination pagination-sm no-margin">
    <#assign collapseLimit = 1,labelLimit = 3 />
    <#assign collapseStart = (labelCurrent - labelLimit - 1 > collapseLimit)/>
    <#assign collapseEnd = (labelCount - (labelCurrent + labelLimit) > collapseLimit)/>

    <#if (labelCurrent > 1)>
        <li><a href="${labelHref?replace("$page",(labelCurrent-1)?c)}"><span>上一页</span></a></li>
    </#if>

    <#if collapseStart>
        <li><a href="${labelHref?replace("$page",1)}"><span>1</span></a></li>
        <li><a href="${labelHref?replace("$page",((labelCurrent - 1) / 2 + 1)?int?c)}"><span>..</span></a></li>
        <#list (labelCurrent - labelLimit)..(labelCurrent-1) as i>
            <li><a href="${labelHref?replace("$page",i?c)}"><span>${i?c}</span></a></li>
        </#list>
    <#else>
        <#list 1..(labelCurrent-1) as i>
            <#if (1>(labelCurrent-1))><#break/></#if>
            <li><a href="${labelHref?replace("$page",i?c)}"><span>${i?c}</span></a></li>
        </#list>
    </#if>

    <li class="active"><span>${labelCurrent?c}</span></li>

    <#if collapseEnd>
        <#list (labelCurrent+1)..(labelCurrent+labelLimit) as i>
            <li><a href="${labelHref?replace("$page",i?c)}"><span>${i?c}</span></a></li>
        </#list>
        <li><a href="${labelHref?replace("$page",((labelCount - labelCurrent) / 2 + labelCurrent + 1)?int?c)}"><span>..</span></a></li>
        <li><a href="${labelHref?replace("$page",labelCount?c)}"><span>${labelCount?c}</span></a></li>
    <#else>
        <#list (labelCurrent+1)..labelCount as i>
            <#if ((labelCurrent+1)>labelCount)><#break/></#if>
            <li><a href="${labelHref?replace("$page",i?c)}"><span>${i?c}</span></a></li>
        </#list>
    </#if>

    <#if labelCurrent<labelCount>
        <li><a href="${labelHref?replace("$page",labelCurrent+1)}"><span>下一页</span></a></li>
    </#if>
</ul>
</#macro>